package com.gln.bloger.service;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import com.gln.bloger.exception.BlogerException;
import com.gln.bloger.pojos.Category;
import com.gln.bloger.pojos.Entry;
import com.gln.bloger.pojos.Website;
import com.gln.bloger.util.PagingSupport;
import com.sun.syndication.feed.synd.SyndFeed;

public interface EntryService {
	
	/**
	 * get entry by entry id
	 * @param entryId
	 * @return
	 * @throws BlogerException
	 */
	public Entry getEntry(String entryId) throws BlogerException;
	
	/**
	 * get previous entry
	 * @param website
	 * @param id
	 * @return
	 * @throws BlogerException
	 */
	public Entry getPreviousEntry(Website website, String id) throws BlogerException;
	/**
	 * get next entry
	 * @param website
	 * @param id
	 * @return
	 * @throws BlogerException
	 */
	public Entry getNextEntry(Website website, String id) throws BlogerException;
	/**
	 * get related entries
	 * @param website
	 * @param entry
	 * @param size
	 * @return
	 * @throws BlogerException
	 */
	public List<Entry> getRelatedEntries (Website website, Entry entry, int size) throws BlogerException; 
	/**
	 * 
	 * for guest
	 * @param includeSecret
	 * @return
	 * @throws BlogerException
	 */
	public PagingSupport<Entry> getEntries(Website website) throws BlogerException;
	
	/**
	 * for author
	 * @param includeSecret
	 * @return
	 * @throws BlogerException
	 */
	public PagingSupport<Entry> getAllEntries(Website website) throws BlogerException;

	/**
	 * 
	 * @param website
	 * @return
	 * @throws BlogerException
	 */
	public List<Entry> getRecentEntries(Website website) throws BlogerException;

	/**
	 * get entries by category name
	 * @param cateName
	 * @throws BlogerException
	 */
	public PagingSupport<Entry> getEntriesByCate(Website website, Category cate) throws BlogerException;
	
	/**
	 * get entries by tag name
	 * @param tagName
	 * @throws BlogerException
	 */
	public PagingSupport<Entry> getEntriesByTag(Website website, String tagId) throws BlogerException;
	/**
	 * get entries archives by month
	 * @param website
	 * @param month
	 * @return
	 * @throws BlogerException
	 */
	public PagingSupport<Entry> getEntriesByMonth(Website website, Date month) throws BlogerException;
	/**
	 * get archived month list
	 * @param website
	 * @return
	 * @throws BlogerException
	 */
	public List<Date> getArchivedMonthList(Website website) throws BlogerException;
	/**
	 * get rss feed
	 * @param feedType
	 * @return
	 * @throws BlogerException
	 */
	public SyndFeed getRssFeed(Website website, String feedType, String contextPath) throws BlogerException;
	/**
	 * save entry
	 * @param entry
	 * @throws ParseException 
	 */
	public void saveOrUpdateEntry(Entry entry, String cateId, String tagStr)throws BlogerException;
	/**
	 * 
	 * @param entry
	 * @throws BlogerException
	 */
	public void saveOrUpdateEntry(Entry entry) throws BlogerException;
	
	/**
	 * 
	 * @param entryId
	 * @throws BlogerException
	 */
	public void removeEntry(String entryId) throws BlogerException;
	/**
	 * clear cached recent entries
	 */
	public void clearCachedRecentEntries();
	/**
	 * clear cached month list
	 */
	public void clearCachedMonthList();

}
